# coding: utf8
# datetime: 2021-03-24
# 题目地址: https://leetcode-cn.com/problems/132-pattern/


from typing import List


class Solution:
    def find132pattern(self, nums: List[int]) -> bool:
        n = len(nums)
        if n < 3:
            return False
        stack = list()
        min = float('-inf')
        for num in nums[::-1]:
            if num < min:
                return True
            while stack and num > stack[-1]:
                min = stack.pop()
            stack.append(num)
        return False

a = Solution()
print(a.find132pattern([1,2,4,3]))